﻿using System;
using System.Runtime.Serialization;
using JetBrains.Annotations;
using MugenMvvmToolkit.Interfaces;
using MugenMvvmToolkit.Interfaces.ViewModels;

namespace MugenMvvmToolkit.Models
{
    /// <summary>
    ///     Represents the initialization context of view-model.
    /// </summary>
#if WPF
    [Serializable]
#endif
    [DataContract]
    public class InitializationContext : IInitializationContext
    {
        #region Constructors

        /// <summary>
        ///     Initializes a new instance of the <see cref="InitializationContext" /> class.
        /// </summary>
        public InitializationContext([NotNull]IIocAdapter iocAdapter, [NotNull] IActivationPolicy context, IViewModel viewModel)
        {
            Should.NotBeNull(iocAdapter, "iocAdapter");
            Should.NotBeNull(context, "context");
            ViewModel = viewModel;
            IocAdapter = iocAdapter;
            ActivationPolicy = context;
        }

        #endregion

        #region Implementation of IInitializationContext

        /// <summary>
        ///     Gets the activation policy.
        /// </summary>
        public IActivationPolicy ActivationPolicy { get; private set; }

        /// <summary>
        ///     Gets the <see cref="IIocAdapter" />.
        /// </summary>
        public IIocAdapter IocAdapter { get; private set; }

        /// <summary>
        ///     Gets or sets the view model which is now initialized.
        /// </summary>
        public IViewModel ViewModel { get; set; }

        /// <summary>
        ///     Gets or sets the parent view model.
        /// </summary>
        public IViewModel ParentViewModel { get; set; }

        #endregion
    }
}